<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>奶牛监测IOT云平台</title>
		<link href="css/mui.min.css" rel="stylesheet" type="text/css">
		<link href="css/new_file.css" rel="stylesheet" type="text/css">
		<link href="css/mui.picker.css" rel="stylesheet" />
		<link href="css/mui.poppicker.css" rel="stylesheet" />
		<link href="css/home.page.css" rel="stylesheet" />
		<link href="css/mui.picker.min.css" rel="stylesheet" >
		
		<script charset="UTF-8" src="js/config.js"></script>
		<script charset="UTF-8" src="js/testActivityName.js"></script>
		<script charset="UTF-8" src="js/core.js"></script>
		<script charset="UTF-8" src="js/cipher-core.js"></script>
		<script charset="UTF-8" src="js/tripledes.js"></script>
		<script charset="UTF-8" src="js/mode-ecb.js"></script>
		<script src="js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="js/zepto.min.js"></script>
		<script type="text/javascript" src="js/spin.min.js"></script>
		<script charset="UTF-8" src="js/mui.min.js"></script>
		<script src="js/echarts.min.js"></script>
		<script charset="UTF-8" src="js/simple.tool.js"></script>
		<script charset="UTF-8" src="js/mui.picker.min.js"></script>
	</head>
	<style>
		.tu-biao{
				margin-left: 50px;
			    margin-bottom: -9px;
			    width: 18px;
			    height: 18px;
			    background-color: red; 
				border-radius: 9px;
			}
		
	</style>
	<div class="spin"></div>
	<body style="background: #f5f5f6; padding-bottom: 50px;">
		<!--<div class="head-zhjf">
			<p style="color: white; font-size: 16px;padding-top: 2px;">奶牛监测IOT云平台</p>
		</div>-->
		<div class="jnx-index-search">
			<div style="margin-top: 20px; ">
				<div class="jnx-idx-cd-a">
					<span style="position: relative;"><img  style="position: absolute; left: -40px;top: -7px;" style="margin-top: 5px;" src="img/sy-rw.png" />今日任务</span>
					<div class="qiehuan-indx"></div>
				</div>
				<div class="jnx-idx-cd-a" onclick="toRecord()">
					<span style="position: relative;"><img  style="position: absolute; width: 25px; left: -25px;" style="margin-top: 5px;" src="img/sy-jl.png" />记录</span>
				</div>
				<div class="clear"></div>
			</div>
		</div>
		<div class="index-banner-div">
			<img src="images/banner@3x.png" style="margin-top: 12px;">
		</div>
		<div class="div-caidan-sy">

			<div class="div-caidan-a" onclick="Oestrus()">
				<img src="images/fqgl-cd@3x.png" />
				<p>发情管理</p>
			</div>
			<div class="div-caidan-a" onclick="Mating()">
				<div id = "noApplicationRecord">
					
				</div>
				<img src="img/diaoluo.png" />
				<p>掉落管理</p>
			</div>
			<div class="div-caidan-a" onclick="Pregnancy()">
				<img src="images/yjgl-cd@3x.png" />
				<p>孕检管理</p>
			</div>
			<div class="div-caidan-a" onclick="abnormal()">
				<img src="images/ycgl-cd@3x.png" />
				<p>入栏管理</p>
			</div>

			<div class="clear"></div>
		</div>

		<div class="sy-tj-bt">
			<div class="sy-tj-l">
				<img src="images/tjlb-img@3x.png" />
				<p style="margin-top:  1px;">统计列表</p>
			</div>
			<div class="sy-tj-r">
				<input type="text" onfocus=this.blur() onclick="dtPicker1('months')" id="months" style=" margin-top: 1px;text-align: right;font-size: 16px;"/>
			</div>
			<div class="clear"></div>
		</div>

		<div style="background: #FFFFFF; padding: 10px 0px;">
			<div class="sy-tj-nr-a" onclick="tjOestrus()" style="margin-top: 4px;">
				<div class="tj-sy-ss">
					<p id="SOestrus">0</p>
				</div>
				<p>疑似发情</p>
			</div>
			<div class="sy-tj-nr-a" onclick="tjMating()">
				<div class="tj-sy-ss">
					<p id="SMating">0</p>
				</div>
				<p>判定发情</p>
			</div>

			<div class="sy-tj-nr-a" onclick="tjPregnancy()">
				<div class="tj-sy-ss">
					<p id="SPregnancy">0</p>
				</div>
				<p>发情揭发</p>
			</div>
			<div class="sy-tj-nr-a" onclick="tjMatched()">
				<div class="tj-sy-ss">
					<p id="Matched">0</p>
				</div>
				<p>待配</p>
			</div>
			<div class="sy-tj-nr-a" onclick="Cattle()">
				<div class="tj-sy-ss">
					<p id="Sabnormal">0</p>
				</div>
				<p>全群总头数</p>
			</div>
			<div class="sy-tj-nr-a" onclick="toBnyj()">
				<div class="tj-sy-ss">
					<p id="bnyj">0</p>
				</div>
				<p>病牛预警</p>
			</div>
			<div class="sy-tj-nr-a" onclick="toBnjf()">
				<div class="tj-sy-ss">
					<p id="bnjf">0</p>
				</div>
				<p>病牛揭发</p>
			</div>
			<div class="clear"></div>
		</div>

		<div class="sy-tj-tu" style="background: #FFFFFF;">
			<div id="main" style="height:300px;width: 100%;"></div>
		</div>

		<div class="bottom-cd">
			<div class="bottom-cd-a" onclick="homePage()">
				<img src="images/sy-cd-01@3x.png" />
				<p style="color: #38adff;">首页</p>
			</div>
			<div class="bottom-cd-a" onclick="FunctionList()">
				<img src="images/gnlb-cd@3x.png" />
				<p>功能列表</p>
			</div>
			<div class="bottom-cd-a" onclick="statisticalAnalysis()">
				<img src="images/tjfx-cd@3x.png" />
				<p>入栏分析</p>
			</div>
			<div class="bottom-cd-a" onclick="PersonalCenter()">
				<img src="images/grzx-cd@3x.png" />
				<p>个人中心</p>
			</div>
		</div>

		<script type="text/javascript">
			var noApplicationRecord = document.getElementById('noApplicationRecord');
			function VersionNo(){
				var keys = JSON.parse(localStorage.getItem('key'));
				var map = {};
				map.key = keys;
				map.phoneType = "android";
				map.language = "zh";
				//map.mapdate=mapdate;
				var jsonStr = JSON.stringify(map);
				$.ajax({
					type: "POST",
					url: url_prefix + "apkVersion",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						// dismissDialog();
						var str11 = decryptByDESModeEBC(data["result"]); //解密
						var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
						var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str12); //转JSON字符串
						var aa1 = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa1 + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							localStorage.setItem('version', JSON.stringify(bb.data[0].version));
							var version = bb.data[0].version
							console.log('version',version)
							 if(version != "1.1.9"){
								mui.alert('该程序有新版本啦！', '更新','下载', function() {
								window.location.href="http://jnx.goldbeacon.cn:8006/profile/appdown/app-release-"+version+".apk"
								});
							} 
						} else {
							mui.alert(bb.head.info);
						}
					},
					error:function () {
						// mui.alert("连接错误");
					}
				});
			}
			
			
			window.onload=appLoad();
			function appLoad() {
				morenDate();
				showData();
				VersionNo();
				bnyj();
			}
			function showData() {
				var keys = JSON.parse(localStorage.getItem('key'));
				var mapdate=JSON.parse(localStorage.getItem('paramsNameDate'));
				var map = {};
				map.key = keys;
				map.phoneType = "android";
				map.language = "zh";
				map.mapdate=mapdate;
				var jsonStr = JSON.stringify(map);
				$.ajax({
					type: "POST",
					url: url_prefix + "main",
					dataType: 'JSON',
					timeout: 10000,
					data: {
						'request': encryptByDES(jsonStr)
					},
					success: function(data) {
						// dismissDialog();
						var str11 = decryptByDESModeEBC(data["result"]); //解密
						var params = str11.replace(/\+/g, " "); //去掉字符串里的+号
						var str12 = UTFTranslate.ReChange(chineseFromUtf8Url(params)); //转utf8
						var datas = JSON.stringify(str12); //转JSON字符串
						var aa1 = datas.replace(/\\n/g, " "); //去掉换行
						var objs = eval('(' + aa1 + ')');
						var bb = eval('(' + objs + ')');
						if(bb.head.status == 1) {
							localStorage.setItem('homePageData', JSON.stringify(bb.data));
							yemianLoading();
						} else {
							mui.alert(bb.head.info);
						}
					},
					error:function () {
						// mui.alert("连接错误");
					}
				});
			}
			function morenDate() {
				var date = new Date();
				var seperator1 = "-";
				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				var strDate = date.getDate();
				if (month >= 1 && month <= 9) {
					month = "0" + month;
				}
				if (strDate >= 0 && strDate <= 9) {
					strDate = "0" + strDate;
				}
				var currentdate = year + seperator1 + month + seperator1 + strDate;
				var paramsNameDate=JSON.parse(localStorage.getItem('paramsNameDate'));
				$('#months').attr("max",currentdate);
				$('#months').val(currentdate);
				localStorage.setItem("paramsNameDate",JSON.stringify(currentdate));
			}
			function yemianLoading() {
				var homePageData = JSON.parse(localStorage.getItem('homePageData'));
				$("#SOestrus").html(homePageData.module.estrus);
				$("#SMating").html(homePageData.module.breeding);
				$("#SPregnancy").html(homePageData.module.pregnancyTest);
				$("#Matched").html(homePageData.module.matched);
				$("#Sabnormal").html(homePageData.module.alarms);
				if(homePageData.num > 0){
					huitu(homePageData);
				}
				// 基于准备好的dom，初始化echarts图表    #1a57be
				var myChart = echarts.init(document.getElementById('main'));
				option = {
					xAxis: [{
						data: homePageData.option.title
					}],
					yAxis: [{
						type: 'value'
					}],
					series: [{
						color : "#1a57be",
						barWidth: 30,
						type: 'bar',
						data: homePageData.option.values,
					}]
				};
				// 为echarts对象加载数据
				myChart.setOption(option);
				var keyStr = JSON.parse(localStorage.getItem("key"));
				var keyManager=window.ws;
				if(keyStr!=undefined){
					if(keyManager!=undefined){
						try{
							keyManager.setKey(keyStr);
						}catch(err){
							mui.alert(err);
						}
					}
				}else{
					if(keyManager!=undefined){
						localStorage.setItem("key",keyManager.getKey());
					}
				}
			}
			$("#months").change(function () {
				localStorage.setItem("paramsNameDate",JSON.stringify($("#months").val()));
				showData();
			});
			function toRecord() {//记录点击
				window.location = "记录.html";
			}
			function dtPicker1(str){
					           var dtPicker = new mui.DtPicker({ type: 'date' });
					           /*参数：'datetime'-完整日期视图(年月日时分)
					                   'date'--年视图(年月日)
					                   'time' --时间视图(时分)
					                   'month'--月视图(年月)
					                   'hour'--时视图(年月日时)
					           */      
					           dtPicker.show(function (selectItems) {
					              var y = selectItems.y.text;  //获取选择的年
					              var m = selectItems.m.text;  //获取选择的月
					              var d = selectItems.d.text;  //获取选择的日
					              var date = y + "-" + m + "-" + d ; 
					              $("#"+str).val(date); 
								  localStorage.setItem("paramsNameDate",JSON.stringify($("#months").val()));
								  showData();
					           })
				}
				function huitu(strData) {
					function setDiv(item) {
						if(item >= 100){
							var div = '<p class="tu-biao" style="color: white;margin-top: -7px;width: 25px;">●●●●</p>'
						}else{
							var div = '<p class="tu-biao" style="color: white;margin-top: -7px;">'+ item +'</p>'
						}
						return div
					}
					function getnoApplicationData() {
						var html = ''
						html += setDiv(strData.num)
						noApplicationRecord.innerHTML = html
					}
					window.onload = getnoApplicationData()
				}
		</script>
		<script src="js/mui.picker.js"></script>
		<script src="js/mui.poppicker.js"></script>
	</body>

</html>